// 轮播
var mySwiper = new Swiper('.swiper-container', {
  loop: true, // 循环模式选项

  // 如果需要前进后退按钮
  navigation: {
    nextEl: '.swiper-button-next',
    prevEl: '.swiper-button-prev',
  },
  autoplay: true,
})


//鼠标覆盖停止自动切换
mySwiper.el.onmouseover = function () {
  mySwiper.autoplay.stop();
}

//鼠标离开开始自动切换
mySwiper.el.onmouseout = function () {
  mySwiper.autoplay.start();
}


// 秒杀轮播
var mySwiperseckill = new Swiper('.swiper-container-seckill', {
  loop: true, // 循环模式选项

  // 如果需要前进后退按钮
  navigation: {
    nextEl: '.swiper-button-next-seckill',
    prevEl: '.swiper-button-prev-seckill',
  },
  autoplay: true,
})

// 服装轮播
var mySwiperclothing = new Swiper('.swiper-container-clothing', {
  loop: true, // 循环模式选项

  // 如果需要前进后退按钮
  navigation: {
    nextEl: '.swiper-button-next-clothing',
    prevEl: '.swiper-button-prev-clothing',
  },
  autoplay: true,
})











// 获取元素
const li = document.querySelectorAll('.nav li')
const clothing = document.querySelector('#clothing')
const h = document.querySelector('#h')
const f = document.querySelector('#f')
const m = document.querySelector('#m')
const showclothing = document.querySelectorAll('.showclothing')
const listbox = document.querySelectorAll('.listbox')



li.forEach((v) => {
  v.addEventListener('mousemove', () => {
    v.style.color = '#feb80f'
  })
  v.addEventListener('mouseout', () => {
    v.style.color = '#9f9f9f'
  })
})

clothing.addEventListener('click', function () {
  location.href = '../productList.html'
  // console.log(123);
})

// 秒杀倒计时
function addDate() {
  let cDate = new Date()

  let fDate = new Date('2021/07/01 12:12:12')

  function bul(n) {
    return n < 10 ? '0' + n : n
  }

  let cha = fDate - cDate

  let hdate = Math.floor(cha / 1000 / 60 / 60 % 24)

  let fdate = Math.floor(cha / 1000 / 60 % 60)

  let mdate = Math.floor(cha / 1000 % 60)

  h.textContent = bul(hdate);
  f.textContent = bul(fdate);
  m.textContent = bul(mdate);
}
addDate()
setInterval(addDate, 1000)




// 服装
listbox.forEach(function (v,i) {
  v.addEventListener('mouseover', () => {
    listbox.forEach((val) => {
      val.className = ''
    })
    
    v.className = 'realize'

    showclothing.forEach(function(v){
       v.style.display = 'none'
    })

    showclothing[i].style.display = 'block'
  })
})